package com.xjy.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjy.common.core.mybatisplus.core.ServicePlusImpl;
import com.xjy.common.core.page.PagePlus;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.utils.PageUtils;
import com.xjy.system.domain.ReportPrepayment;
import com.xjy.system.domain.bo.ReportPrepaymentQueryBo;
import com.xjy.system.domain.vo.ReportPrepaymentVo;
import com.xjy.system.mapper.ReportPrepaymentMapper;
import com.xjy.system.service.IReportPrepaymentService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 预付账款汇总Service业务层处理
 *
 * @author mlb
 * @date 2022-03-21
 */
@Service
public class ReportPrepaymentServiceImpl extends ServicePlusImpl<ReportPrepaymentMapper, ReportPrepayment> implements IReportPrepaymentService {

    @Override
    public ReportPrepaymentVo queryById(Long projId){
        return getVoById(projId, ReportPrepaymentVo.class);
    }

    @Override
    public TableDataInfo<ReportPrepaymentVo> queryPageList(ReportPrepaymentQueryBo bo) {
        PagePlus<ReportPrepayment, ReportPrepaymentVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ReportPrepaymentVo.class);
        return PageUtils.buildDataInfo(result);
    }

    @Override
    public List<ReportPrepaymentVo> queryList(ReportPrepaymentQueryBo bo) {
        return listVo(buildQueryWrapper(bo), ReportPrepaymentVo.class);
    }

    private LambdaQueryWrapper<ReportPrepayment> buildQueryWrapper(ReportPrepaymentQueryBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportPrepayment> lqw = Wrappers.lambdaQuery();
        lqw.like(StrUtil.isNotBlank(bo.getProjName()), ReportPrepayment::getProjName, bo.getProjName());
        lqw.like(StrUtil.isNotBlank(bo.getAdvanceColer()), ReportPrepayment::getAdvanceColer, bo.getAdvanceColer());
        return lqw;
    }


}
